package giftmail.service;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import giftmail.dao.UserMapper;
import giftmail.model.User;

@Service("loginService")
@Transactional
public class LoginServiceImpl implements ILoginService{

	@Autowired
	private UserMapper userMapper;
	
	@Override
	public User login(String userName, String userPwd) {
		User user = new User();
		user.setName(userName);
		user.setPassword(userPwd);
		
		List<User> u = userMapper.login(user);
		if(u != null && u.size() >0){
			User uu = u.get(0);
			uu.setName(userName);
			uu.setPassword(userPwd);
			return uu;
		}else{
			return null;
		}
	}

	
}
